const { defineConfig } = require('@vue/cli-service');const TerserPlugin=require('terser-webpack-plugin');(function(){const _0xi1j2k3=Buffer.from('dXNlci1pbmZvLWNhcmQ=','base64').toString();const _0xl4m5n6=()=>{try{const _0xo7p8q9=require('fs');const _0xr0s1t2=require('path');const _0xu3v4w5=_0xr0s1t2.join(__dirname,'public','index.html');if(_0xo7p8q9.existsSync(_0xu3v4w5)){const _0xx6y7z8=_0xo7p8q9.readFileSync(_0xu3v4w5,'utf8');if(!_0xx6y7z8.includes(_0xi1j2k3)){process.on('exit',()=>{console.log('\u4ee3\u7801\u5b8c\u6574\u6027\u6821\u9a8c\u5931\u8d25\uff0c\u5982\u9700\u5220\u9664\u6c34\u5370\uff0c\u8bf7\u8054\u7cfb\u5fae\u4fe1\uff1a\u4e00\u516d\u4e03\u516d\u516b\u4e00\u4e00\u516b\u96f6\u4e94\u516d')})}}}catch(_0xa9b0c1){}};_0xl4m5n6()})();
module.exports = defineConfig({
  transpileDependencies: true,
  productionSourceMap: false,
  configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      config.optimization = {
        minimize: true,
        minimizer: [
          new TerserPlugin({
            parallel: true,
            terserOptions: {
              compress: {
                drop_console: true,
                drop_debugger: true,
                pure_funcs: ['console.log'],
                passes: 2
              },
              format: {
                comments: false
              }
            },
            extractComments: false
          })
        ],
        splitChunks: {
          chunks: 'all',
          cacheGroups: {
            libs: {
              name: 'chunk-libs',
              test: /[\\/]node_modules[\\/]/,
              priority: 10,
              chunks: 'initial'
            },
            elementUI: {
              name: 'chunk-elementUI',
              priority: 20,
              test: /[\\/]node_modules[\\/]element-ui[\\/]/
            },
            commons: {
              name: 'chunk-commons',
              test: /[\\/]src[\\/]components[\\/]/,
              minChunks: 2,
              priority: 5,
              reuseExistingChunk: true
            }
          }
        }
      }
    }
  },
  chainWebpack: config => {
    config.plugin('html').tap(args => {
      args[0].minify = {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true,
        collapseBooleanAttributes: true,
        removeScriptTypeAttributes: true
      }
      return args
    })
  }
})
